package com.tulink.yichutu.controller.weixin;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import com.tulink.yichutu.common.utils.DataResult;

import com.tulink.yichutu.entity.WxQrcodeEntity;
import com.tulink.yichutu.service.WxQrcodeService;



/**
 * 微信扫码表
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2021-04-04 20:05:01
 */
@Controller
@RequestMapping("/")
public class WxQrcodeController {
    @Autowired
    private WxQrcodeService wxQrcodeService;


    /**
    * 跳转到页面
    */
    @GetMapping("/index/wxQrcode")
    public String wxQrcode() {
        return "wxqrcode/list";
        }

    @ApiOperation(value = "新增")
    @PostMapping("wxQrcode/add")
    @RequiresPermissions("wxQrcode:add")
    @ResponseBody
    public DataResult add(@RequestBody WxQrcodeEntity wxQrcode){
        wxQrcodeService.save(wxQrcode);
        return DataResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("wxQrcode/delete")
    @RequiresPermissions("wxQrcode:delete")
    @ResponseBody
    public DataResult delete(@RequestBody @ApiParam(value = "id集合") List<String> ids){
        wxQrcodeService.removeByIds(ids);
        return DataResult.success();
    }

    @ApiOperation(value = "更新")
    @PutMapping("wxQrcode/update")
    @RequiresPermissions("wxQrcode:update")
    @ResponseBody
    public DataResult update(@RequestBody WxQrcodeEntity wxQrcode){
        wxQrcodeService.updateById(wxQrcode);
        return DataResult.success();
    }

    @ApiOperation(value = "查询分页数据")
    @PostMapping("wxQrcode/listByPage")
    @RequiresPermissions("wxQrcode:list")
    @ResponseBody
    public DataResult findListByPage(@RequestBody WxQrcodeEntity wxQrcode){
        Page page = new Page(wxQrcode.getPage(), wxQrcode.getLimit());
        LambdaQueryWrapper<WxQrcodeEntity> queryWrapper = Wrappers.lambdaQuery();
        //查询条件示例
        //queryWrapper.eq(WxQrcodeEntity::getId, wxQrcode.getId());
        IPage<WxQrcodeEntity> iPage = wxQrcodeService.page(page, queryWrapper);
        return DataResult.success(iPage);
    }

}
